/*
 * Creado por NIN
 * User: sebastian.lucas
 * Date: 19/04/2007
 * Time: 9:23
 */

using System;
using System.Drawing;
using System.Drawing.Imaging;

namespace CSE
{
	/// <summary>
	/// Description of Stage.
	/// </summary>
	public class Stage
	{
	    /*
	     * Constants
	     */
	    public static readonly int GRID_SIZE = 40;
	    
	    /*
	     * Variables
	     */
	    public static Bitmap bmp = null;
	    
	    /*
	     * Init
	     */
	    public static void Init ()
	    {
	        if (bmp != null)
	        {
	            return;
	        }
	        
	        bmp = Utils.LoadBitmapResource("grid.Bitmap");
	        
	        if (bmp == null)
	        {
	            Utils.Trace("NULL!");
	        }
	    }
	    
	    /*
	     * Shutdown
	     */
	    public static void Shutdown ()
	    {
	    }
	    
	    /*
	     * =============================================================================================
	     * Draw Stuff
	     */
	    
	    /*
	     * DrawGrid
	     */
	    public static void DrawGrid (Graphics g, int w, int h)
	    {
	        int x=0, y=0, xs=w/GRID_SIZE, ys=h/GRID_SIZE;
	        
	        xs++;
	        ys++;
	        
	        if (bmp == null)
	        {
	            Utils.Trace("bmp is null");
	            return;
	        }
	        
	        for (y=0; y<ys; y++)
	        {
	            for (x=0; x<xs; x++)
	            {
	                g.DrawImage(bmp, x*GRID_SIZE, y*GRID_SIZE);
	            }
	        }
	    }
	    
	    /*
	     * Draw
	     */
	    public static void Draw (Graphics g, int w, int h)
	    {
	        if (Workspace.type == Workspace.TYPE_NONE)
	        {
	            return;
	        }
	        
	        DrawGrid(g, w, h);
	        
	        g.Flush();
	    }
	}
}
